/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    ap-northeast-2-pop = 'arms.aliyuncs.com',
    cn-beijing-finance-1 = 'arms.aliyuncs.com',
    cn-beijing-finance-pop = 'arms.aliyuncs.com',
    cn-beijing-gov-1 = 'arms.aliyuncs.com',
    cn-beijing-nu16-b01 = 'arms.aliyuncs.com',
    cn-edge-1 = 'arms.aliyuncs.com',
    cn-fujian = 'arms.aliyuncs.com',
    cn-haidian-cm12-c01 = 'arms.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'arms.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'arms.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'arms.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'arms.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'arms.aliyuncs.com',
    cn-hangzhou-test-306 = 'arms.aliyuncs.com',
    cn-hongkong-finance-pop = 'arms.aliyuncs.com',
    cn-huhehaote-nebula-1 = 'arms.aliyuncs.com',
    cn-qingdao-nebula = 'arms.aliyuncs.com',
    cn-shanghai-et15-b01 = 'arms.aliyuncs.com',
    cn-shanghai-et2-b01 = 'arms.aliyuncs.com',
    cn-shanghai-inner = 'arms.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'arms.aliyuncs.com',
    cn-shenzhen-inner = 'arms.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'arms.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'arms.aliyuncs.com',
    cn-wuhan = 'arms.aliyuncs.com',
    cn-yushanfang = 'arms.aliyuncs.com',
    cn-zhangbei = 'arms.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'arms.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'arms.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'arms.aliyuncs.com',
    eu-west-1-oxs = 'arms.aliyuncs.com',
    me-east-1 = 'arms.aliyuncs.com',
    rus-west-1-pop = 'arms.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('arms', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ARMSQueryDataSetRequest {
  datasetId?: long(name='DatasetId'),
  dateStr?: string(name='DateStr'),
  dimensions?: [ 
    {
      key?: string(name='Key'),
      type?: string(name='Type'),
      value?: string(name='Value'),
    }
  ](name='Dimensions'),
  hungryMode?: boolean(name='HungryMode'),
  intervalInSec?: int32(name='IntervalInSec'),
  isDrillDown?: boolean(name='IsDrillDown'),
  limit?: int32(name='Limit'),
  maxTime?: long(name='MaxTime'),
  measures?: [ string ](name='Measures'),
  minTime?: long(name='MinTime'),
  optionalDims?: [ 
    {
      key?: string(name='Key'),
      type?: string(name='Type'),
      value?: string(name='Value'),
    }
  ](name='OptionalDims'),
  orderByKey?: string(name='OrderByKey'),
  reduceTail?: boolean(name='ReduceTail'),
  requiredDims?: [ 
    {
      key?: string(name='Key'),
      type?: string(name='Type'),
      value?: string(name='Value'),
    }
  ](name='RequiredDims'),
  securityToken?: string(name='SecurityToken'),
}

model ARMSQueryDataSetResponseBody = {
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model ARMSQueryDataSetResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ARMSQueryDataSetResponseBody(name='body'),
}

async function aRMSQueryDataSetWithOptions(request: ARMSQueryDataSetRequest, runtime: Util.RuntimeOptions): ARMSQueryDataSetResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.datasetId)) {
    query['DatasetId'] = request.datasetId;
  }
  if (!Util.isUnset(request.dateStr)) {
    query['DateStr'] = request.dateStr;
  }
  if (!Util.isUnset(request.dimensions)) {
    query['Dimensions'] = request.dimensions;
  }
  if (!Util.isUnset(request.hungryMode)) {
    query['HungryMode'] = request.hungryMode;
  }
  if (!Util.isUnset(request.intervalInSec)) {
    query['IntervalInSec'] = request.intervalInSec;
  }
  if (!Util.isUnset(request.isDrillDown)) {
    query['IsDrillDown'] = request.isDrillDown;
  }
  if (!Util.isUnset(request.limit)) {
    query['Limit'] = request.limit;
  }
  if (!Util.isUnset(request.maxTime)) {
    query['MaxTime'] = request.maxTime;
  }
  if (!Util.isUnset(request.measures)) {
    query['Measures'] = request.measures;
  }
  if (!Util.isUnset(request.minTime)) {
    query['MinTime'] = request.minTime;
  }
  if (!Util.isUnset(request.optionalDims)) {
    query['OptionalDims'] = request.optionalDims;
  }
  if (!Util.isUnset(request.orderByKey)) {
    query['OrderByKey'] = request.orderByKey;
  }
  if (!Util.isUnset(request.reduceTail)) {
    query['ReduceTail'] = request.reduceTail;
  }
  if (!Util.isUnset(request.requiredDims)) {
    query['RequiredDims'] = request.requiredDims;
  }
  if (!Util.isUnset(request.securityToken)) {
    query['SecurityToken'] = request.securityToken;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ARMSQueryDataSet',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function aRMSQueryDataSet(request: ARMSQueryDataSetRequest): ARMSQueryDataSetResponse {
  var runtime = new Util.RuntimeOptions{};
  return aRMSQueryDataSetWithOptions(request, runtime);
}

model CreateAlertContactRequest {
  contactName?: string(name='ContactName'),
  dingRobotWebhookUrl?: string(name='DingRobotWebhookUrl'),
  email?: string(name='Email'),
  phoneNum?: string(name='PhoneNum'),
  systemNoc?: boolean(name='SystemNoc'),
}

model CreateAlertContactResponseBody = {
  contactId?: string(name='ContactId'),
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model CreateAlertContactResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateAlertContactResponseBody(name='body'),
}

async function createAlertContactWithOptions(request: CreateAlertContactRequest, runtime: Util.RuntimeOptions): CreateAlertContactResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.contactName)) {
    query['ContactName'] = request.contactName;
  }
  if (!Util.isUnset(request.dingRobotWebhookUrl)) {
    query['DingRobotWebhookUrl'] = request.dingRobotWebhookUrl;
  }
  if (!Util.isUnset(request.email)) {
    query['Email'] = request.email;
  }
  if (!Util.isUnset(request.phoneNum)) {
    query['PhoneNum'] = request.phoneNum;
  }
  if (!Util.isUnset(request.systemNoc)) {
    query['SystemNoc'] = request.systemNoc;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateAlertContact',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createAlertContact(request: CreateAlertContactRequest): CreateAlertContactResponse {
  var runtime = new Util.RuntimeOptions{};
  return createAlertContactWithOptions(request, runtime);
}

model CreateAlertContactGroupRequest {
  contactGroupName?: string(name='ContactGroupName'),
  contactIds?: string(name='ContactIds'),
}

model CreateAlertContactGroupResponseBody = {
  contactGroupId?: string(name='ContactGroupId'),
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model CreateAlertContactGroupResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateAlertContactGroupResponseBody(name='body'),
}

async function createAlertContactGroupWithOptions(request: CreateAlertContactGroupRequest, runtime: Util.RuntimeOptions): CreateAlertContactGroupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.contactGroupName)) {
    query['ContactGroupName'] = request.contactGroupName;
  }
  if (!Util.isUnset(request.contactIds)) {
    query['ContactIds'] = request.contactIds;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateAlertContactGroup',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createAlertContactGroup(request: CreateAlertContactGroupRequest): CreateAlertContactGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return createAlertContactGroupWithOptions(request, runtime);
}

model GetIpOrHostsRequest {
  endTime?: long(name='EndTime'),
  regionId?: string(name='RegionId'),
  serviceName?: string(name='ServiceName'),
  startTime?: long(name='StartTime'),
}

model GetIpOrHostsResponseBody = {
  data?: {
    data?: [ string ](name='Data')
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetIpOrHostsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetIpOrHostsResponseBody(name='body'),
}

async function getIpOrHostsWithOptions(request: GetIpOrHostsRequest, runtime: Util.RuntimeOptions): GetIpOrHostsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.serviceName)) {
    query['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetIpOrHosts',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getIpOrHosts(request: GetIpOrHostsRequest): GetIpOrHostsResponse {
  var runtime = new Util.RuntimeOptions{};
  return getIpOrHostsWithOptions(request, runtime);
}

model GetServicesRequest {
  appType?: string(name='AppType'),
  regionId?: string(name='RegionId'),
}

model GetServicesResponseBody = {
  data?: {
    details?: {
      details?: [ 
      {
        pid?: string(name='Pid'),
        regionId?: string(name='RegionId'),
        serviceName?: string(name='ServiceName'),
      }
    ](name='Details')
    }(name='Details'),
    services?: {
      services?: [ string ](name='Services')
    }(name='Services'),
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetServicesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetServicesResponseBody(name='body'),
}

async function getServicesWithOptions(request: GetServicesRequest, runtime: Util.RuntimeOptions): GetServicesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.appType)) {
    query['AppType'] = request.appType;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetServices',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getServices(request: GetServicesRequest): GetServicesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getServicesWithOptions(request, runtime);
}

model GetSpanNamesRequest {
  endTime?: long(name='EndTime'),
  regionId?: string(name='RegionId'),
  serviceName?: string(name='ServiceName'),
  startTime?: long(name='StartTime'),
}

model GetSpanNamesResponseBody = {
  data?: {
    data?: [ string ](name='Data')
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetSpanNamesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetSpanNamesResponseBody(name='body'),
}

async function getSpanNamesWithOptions(request: GetSpanNamesRequest, runtime: Util.RuntimeOptions): GetSpanNamesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.serviceName)) {
    query['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetSpanNames',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getSpanNames(request: GetSpanNamesRequest): GetSpanNamesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getSpanNamesWithOptions(request, runtime);
}

model GetTagKeyRequest {
  endTime?: long(name='EndTime'),
  regionId?: string(name='RegionId'),
  serviceName?: string(name='ServiceName'),
  spanName?: string(name='SpanName'),
  startTime?: long(name='StartTime'),
}

model GetTagKeyResponseBody = {
  data?: {
    data?: [ string ](name='Data')
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetTagKeyResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetTagKeyResponseBody(name='body'),
}

async function getTagKeyWithOptions(request: GetTagKeyRequest, runtime: Util.RuntimeOptions): GetTagKeyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.serviceName)) {
    query['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.spanName)) {
    query['SpanName'] = request.spanName;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTagKey',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getTagKey(request: GetTagKeyRequest): GetTagKeyResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTagKeyWithOptions(request, runtime);
}

model GetTagValRequest {
  endTime?: long(name='EndTime'),
  regionId?: string(name='RegionId'),
  serviceName?: string(name='ServiceName'),
  spanName?: string(name='SpanName'),
  startTime?: long(name='StartTime'),
  tagKey?: string(name='TagKey'),
}

model GetTagValResponseBody = {
  data?: {
    data?: [ string ](name='Data')
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetTagValResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetTagValResponseBody(name='body'),
}

async function getTagValWithOptions(request: GetTagValRequest, runtime: Util.RuntimeOptions): GetTagValResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.serviceName)) {
    query['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.spanName)) {
    query['SpanName'] = request.spanName;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  if (!Util.isUnset(request.tagKey)) {
    query['TagKey'] = request.tagKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTagVal',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getTagVal(request: GetTagValRequest): GetTagValResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTagValWithOptions(request, runtime);
}

model GetTokenRequest {
  appType?: string(name='AppType'),
  regionId?: string(name='RegionId'),
}

model GetTokenResponseBody = {
  data?: {
    domain?: string(name='Domain'),
    internalDomain?: string(name='InternalDomain'),
    licenseKey?: string(name='LicenseKey'),
    pid?: string(name='Pid'),
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetTokenResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetTokenResponseBody(name='body'),
}

async function getTokenWithOptions(request: GetTokenRequest, runtime: Util.RuntimeOptions): GetTokenResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.appType)) {
    query['AppType'] = request.appType;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetToken',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getToken(request: GetTokenRequest): GetTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTokenWithOptions(request, runtime);
}

model GetTraceRequest {
  appType?: string(name='AppType'),
  regionId?: string(name='RegionId'),
  traceID?: string(name='TraceID'),
}

model GetTraceResponseBody = {
  data?: {
    callChainInfo?: [ 
    {
      duration?: long(name='Duration'),
      haveStack?: boolean(name='HaveStack'),
      logEventList?: {
        logEvent?: [ 
        {
          tagEntryList?: {
            tagEntry?: [ 
            {
              key?: string(name='Key'),
              value?: string(name='Value'),
            }
          ](name='TagEntry')
          }(name='TagEntryList'),
          timestamp?: long(name='Timestamp'),
        }
      ](name='LogEvent')
      }(name='LogEventList'),
      operationName?: string(name='OperationName'),
      resultCode?: string(name='ResultCode'),
      rpcId?: string(name='RpcId'),
      serviceIp?: string(name='ServiceIp'),
      serviceName?: string(name='ServiceName'),
      tagEntryList?: {
        tagEntry?: [ 
        {
          key?: string(name='Key'),
          value?: string(name='Value'),
        }
      ](name='TagEntry')
      }(name='TagEntryList'),
      timestamp?: long(name='Timestamp'),
      traceID?: string(name='TraceID'),
    }
  ](name='CallChainInfo')
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetTraceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetTraceResponseBody(name='body'),
}

async function getTraceWithOptions(request: GetTraceRequest, runtime: Util.RuntimeOptions): GetTraceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.appType)) {
    query['AppType'] = request.appType;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.traceID)) {
    query['TraceID'] = request.traceID;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTrace',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getTrace(request: GetTraceRequest): GetTraceResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTraceWithOptions(request, runtime);
}

model GetTraceAppsRequest {
  regionId?: string(name='RegionId'),
}

model GetTraceAppsResponseBody = {
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetTraceAppsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetTraceAppsResponseBody(name='body'),
}

async function getTraceAppsWithOptions(request: GetTraceAppsRequest, runtime: Util.RuntimeOptions): GetTraceAppsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTraceApps',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getTraceApps(request: GetTraceAppsRequest): GetTraceAppsResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTraceAppsWithOptions(request, runtime);
}

model ImportAppAlertRulesRequest {
  contactGroupIds?: string(name='ContactGroupIds'),
  isAutoStart?: boolean(name='IsAutoStart'),
  pids?: string(name='Pids'),
  regionId?: string(name='RegionId'),
  templateAlertId?: string(name='TemplateAlertId'),
}

model ImportAppAlertRulesResponseBody = {
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model ImportAppAlertRulesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ImportAppAlertRulesResponseBody(name='body'),
}

async function importAppAlertRulesWithOptions(request: ImportAppAlertRulesRequest, runtime: Util.RuntimeOptions): ImportAppAlertRulesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.contactGroupIds)) {
    query['ContactGroupIds'] = request.contactGroupIds;
  }
  if (!Util.isUnset(request.isAutoStart)) {
    query['IsAutoStart'] = request.isAutoStart;
  }
  if (!Util.isUnset(request.pids)) {
    query['Pids'] = request.pids;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.templateAlertId)) {
    query['TemplateAlertId'] = request.templateAlertId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ImportAppAlertRules',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function importAppAlertRules(request: ImportAppAlertRulesRequest): ImportAppAlertRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  return importAppAlertRulesWithOptions(request, runtime);
}

model MetricQueryRequest {
  customFilters?: string(name='CustomFilters'),
  dimensions?: [ string ](name='Dimensions'),
  endTime?: long(name='EndTime'),
  filters?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Filters'),
  iintervalInSec?: int32(name='IintervalInSec'),
  limit?: int32(name='Limit'),
  measures?: [ string ](name='Measures'),
  metric?: string(name='Metric'),
  order?: string(name='Order'),
  orderBy?: string(name='OrderBy'),
  securityToken?: string(name='SecurityToken'),
  startTime?: long(name='StartTime'),
  where?: string(name='Where'),
}

model MetricQueryResponseBody = {
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model MetricQueryResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: MetricQueryResponseBody(name='body'),
}

async function metricQueryWithOptions(request: MetricQueryRequest, runtime: Util.RuntimeOptions): MetricQueryResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.customFilters)) {
    query['CustomFilters'] = request.customFilters;
  }
  if (!Util.isUnset(request.dimensions)) {
    query['Dimensions'] = request.dimensions;
  }
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.filters)) {
    query['Filters'] = request.filters;
  }
  if (!Util.isUnset(request.iintervalInSec)) {
    query['IintervalInSec'] = request.iintervalInSec;
  }
  if (!Util.isUnset(request.limit)) {
    query['Limit'] = request.limit;
  }
  if (!Util.isUnset(request.measures)) {
    query['Measures'] = request.measures;
  }
  if (!Util.isUnset(request.metric)) {
    query['Metric'] = request.metric;
  }
  if (!Util.isUnset(request.order)) {
    query['Order'] = request.order;
  }
  if (!Util.isUnset(request.orderBy)) {
    query['OrderBy'] = request.orderBy;
  }
  if (!Util.isUnset(request.securityToken)) {
    query['SecurityToken'] = request.securityToken;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  if (!Util.isUnset(request.where)) {
    query['Where'] = request.where;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'MetricQuery',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function metricQuery(request: MetricQueryRequest): MetricQueryResponse {
  var runtime = new Util.RuntimeOptions{};
  return metricQueryWithOptions(request, runtime);
}

model SearchAlertContactRequest {
  contactName?: string(name='ContactName'),
  currentPage?: string(name='CurrentPage'),
  email?: string(name='Email'),
  pageSize?: string(name='PageSize'),
  phone?: string(name='Phone'),
}

model SearchAlertContactResponseBody = {
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model SearchAlertContactResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SearchAlertContactResponseBody(name='body'),
}

async function searchAlertContactWithOptions(request: SearchAlertContactRequest, runtime: Util.RuntimeOptions): SearchAlertContactResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.contactName)) {
    query['ContactName'] = request.contactName;
  }
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.email)) {
    query['Email'] = request.email;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.phone)) {
    query['Phone'] = request.phone;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SearchAlertContact',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function searchAlertContact(request: SearchAlertContactRequest): SearchAlertContactResponse {
  var runtime = new Util.RuntimeOptions{};
  return searchAlertContactWithOptions(request, runtime);
}

model SearchAlertContactGroupRequest {
  contactGroupName?: string(name='ContactGroupName'),
}

model SearchAlertContactGroupResponseBody = {
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model SearchAlertContactGroupResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SearchAlertContactGroupResponseBody(name='body'),
}

async function searchAlertContactGroupWithOptions(request: SearchAlertContactGroupRequest, runtime: Util.RuntimeOptions): SearchAlertContactGroupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.contactGroupName)) {
    query['ContactGroupName'] = request.contactGroupName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SearchAlertContactGroup',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function searchAlertContactGroup(request: SearchAlertContactGroupRequest): SearchAlertContactGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return searchAlertContactGroupWithOptions(request, runtime);
}

model SearchTraceCountRequest {
  appType?: string(name='AppType'),
  endTime?: long(name='EndTime'),
  minDuration?: long(name='MinDuration'),
  operationName?: string(name='OperationName'),
  regionId?: string(name='RegionId'),
  serviceIp?: string(name='ServiceIp'),
  serviceName?: string(name='ServiceName'),
  startTime?: long(name='StartTime'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model SearchTraceCountResponseBody = {
  data?: {
    count?: long(name='Count'),
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model SearchTraceCountResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SearchTraceCountResponseBody(name='body'),
}

async function searchTraceCountWithOptions(request: SearchTraceCountRequest, runtime: Util.RuntimeOptions): SearchTraceCountResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.appType)) {
    query['AppType'] = request.appType;
  }
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.minDuration)) {
    query['MinDuration'] = request.minDuration;
  }
  if (!Util.isUnset(request.operationName)) {
    query['OperationName'] = request.operationName;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.serviceIp)) {
    query['ServiceIp'] = request.serviceIp;
  }
  if (!Util.isUnset(request.serviceName)) {
    query['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SearchTraceCount',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function searchTraceCount(request: SearchTraceCountRequest): SearchTraceCountResponse {
  var runtime = new Util.RuntimeOptions{};
  return searchTraceCountWithOptions(request, runtime);
}

model SearchTracesRequest {
  appType?: string(name='AppType'),
  endTime?: long(name='EndTime'),
  minDuration?: long(name='MinDuration'),
  operationName?: string(name='OperationName'),
  pageIndex?: int32(name='PageIndex'),
  pageSize?: int32(name='PageSize'),
  regionId?: string(name='RegionId'),
  reverse?: boolean(name='Reverse'),
  serviceIp?: string(name='ServiceIp'),
  serviceName?: string(name='ServiceName'),
  startTime?: long(name='StartTime'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model SearchTracesResponseBody = {
  data?: {
    traceInfo?: [ 
    {
      duration?: int32(name='Duration'),
      operationName?: string(name='OperationName'),
      serviceIp?: string(name='ServiceIp'),
      serviceName?: string(name='ServiceName'),
      timestamp?: long(name='Timestamp'),
      traceID?: string(name='TraceID'),
    }
  ](name='TraceInfo')
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model SearchTracesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SearchTracesResponseBody(name='body'),
}

async function searchTracesWithOptions(request: SearchTracesRequest, runtime: Util.RuntimeOptions): SearchTracesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.appType)) {
    query['AppType'] = request.appType;
  }
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.minDuration)) {
    query['MinDuration'] = request.minDuration;
  }
  if (!Util.isUnset(request.operationName)) {
    query['OperationName'] = request.operationName;
  }
  if (!Util.isUnset(request.pageIndex)) {
    query['PageIndex'] = request.pageIndex;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.reverse)) {
    query['Reverse'] = request.reverse;
  }
  if (!Util.isUnset(request.serviceIp)) {
    query['ServiceIp'] = request.serviceIp;
  }
  if (!Util.isUnset(request.serviceName)) {
    query['ServiceName'] = request.serviceName;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SearchTraces',
    version = '2019-02-19',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function searchTraces(request: SearchTracesRequest): SearchTracesResponse {
  var runtime = new Util.RuntimeOptions{};
  return searchTracesWithOptions(request, runtime);
}

